package logic

import (
	"context"
	"tiktok/models/mysql"

	"tiktok/tiktokrpc/internal/svc"
	"tiktok/tiktokrpc/tiktokrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type NoteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewNoteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NoteLogic {
	return &NoteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 笔记创建
func (l *NoteLogic) Note(in *tiktokrpc.NoteRequest) (*tiktokrpc.NoteResponse, error) {
	// todo: add your logic here and delete this line
	note := mysql.Note{
		UserId:  int(in.UserId),
		Title:   in.Title,
		Context: in.Context,
	}
	mysql.DB.Create(&note)
	return &tiktokrpc.NoteResponse{
		Id: int64(note.ID),
	}, nil
}
